

import { MeasureAction, MeasureActionTypes } from '../actions';

export interface MeasureState {
    distance: boolean,
    acreage: boolean,
    clear: boolean
}

export const initialMeasureState: MeasureState = {
    distance: false,
    acreage: false,
    clear: false
};

export function measureReducer(state: MeasureState = initialMeasureState, action: MeasureAction): MeasureState {
    switch(action.type) {
        case MeasureActionTypes.MEASURE_DISTANCE: {
            return {
                ...state,
                distance: true,
                acreage: false,
                clear: false
            }
        }
        case MeasureActionTypes.MEASURE_ACREAGE: {
            return {
                ...state,
                distance: false,
                acreage: true,
                clear: false
            }
        }
        case MeasureActionTypes.MEASURE_CLEAR: {
            return {
                ...state,
                distance: false,
                acreage: false,
                clear: true
            }
        }
        default: {
            return state;
        }
    }
}